//
//  BackupsSwitchView.swift
//  imprint
//
//  Created by 小柠檬🍋 on 2025/1/27.
//

import SwiftUI

//日期模式弹窗
struct DateModeDialogView: View {
    let onDismiss: () -> Void
    var body: some View {
        PopupBottomView(title: "时间试图切换") {
            VStack(spacing: 15) {
                HStack {
                    Text("当日记录")
                        .font(.system(size: 16))
                        .foregroundStyle(.bgNormalText2)
                }.padding(.horizontal,15)
                    .frame(height: 80)
                    .frame(maxWidth: .infinity)
                    .background(AppStorageManager.shared.dateMode == IDateModeType.DAY ? themeManager.themeColor.opacity(0.2) : .bgItemGray)
                    .cornerRadius(15)
                    .contentShape(Rectangle())
                    .onTapGesture {
                        AppStorageManager.shared.dateMode = IDateModeType.DAY
                        onDismiss()
                    }
                HStack {
                    Text("月记录")
                        .font(.system(size: 16))
                        .foregroundStyle(.bgNormalText2)
                }.padding(.horizontal,15)
                    .frame(height: 80)
                    .frame(maxWidth: .infinity)
                    .background(AppStorageManager.shared.dateMode == IDateModeType.MONTH ? themeManager.themeColor.opacity(0.2) : .bgItemGray)
                    .cornerRadius(15)
                    .contentShape(Rectangle())
                    .onTapGesture {
                        AppStorageManager.shared.dateMode = IDateModeType.MONTH
                        onDismiss()
                    }
                HStack {
                    HStack {
                        Text("年记录")
                            .font(.system(size: 16))
                            .foregroundStyle(.bgNormalText2)
                        Image(.appIconVip)
                            .resizable()
                            .frame(width: 20,height: 20)
                    }
                }.padding(.horizontal,15)
                    .frame(height: 80)
                    .frame(maxWidth: .infinity)
                    .background(AppStorageManager.shared.dateMode == IDateModeType.YEAR ? themeManager.themeColor.opacity(0.2) : .bgItemGray)
                    .cornerRadius(15)
                    .contentShape(Rectangle())
                    .onTapGesture {
                        AppStorageManager.shared.dateMode = IDateModeType.YEAR
                        onDismiss()
                    }
            }.padding(.top,15)
        }
    }
}

//#Preview {
//    DateModeDialogView()
//}
//定义预览提供者
struct DateModeDialogView_Previews: PreviewProvider {
    static var previews: some View {
        //使用预览共享配置
        configurePreviewEnvironment(for: DateModeDialogView(){})
    }
}
